var app = angular.module("myApp", ["ui.router"]); 

app.run(function($rootScope){
	$rootScope.color = "blue" ;
});

app.config(function($stateProvider, $urlRouterProvider){
	
	//$urlRouterProvider.otherwise("/state1")
	
	$stateProvider
	.state("state1", {
		url: "/state1",
		templateUrl: "tpls/state1.html"
	})
	.state("state1.list", {
		url: "/list",
		templateUrl: "tpls/state3.html",
		controller: "myCtrl"
	})
	.state("state2", {
		url: "/state2?myParam1&myParam2",
		params: {
			aa: 1
		},
		templateUrl: "tpls/state2.html"
	})
	.state("state2.list", {
		url: "/list/{aa:int}",
		templateUrl: function($stateParams) {
			console.info($stateParams) ;
			return "tpls/state4.html" ;
		},
		controller: function ($stateParams) {
            console.info($stateParams);
        }
	});
	
	
	$stateProvider.state("index", {
		url: "",
		views: {
			"viewB": {templateUrl: "tpls/page1.html"}
		}
	})
	.state("view-b", {
		url: "/view-b",
		views: {
			"": {templateUrl: "tpls/main.html"},
			"viewB": {templateUrl: "tpls/page1.html"}
		}
		
	});
	
});

